﻿using System.Threading.Channels;

var unboundedChannel = Channel.CreateUnbounded<string>();

 _ = Task.Factory.StartNew(async () =>
    {
        for (int i = 0; i < 10; i++)
        {
            await unboundedChannel.Writer.WriteAsync($"Hello World {i}");
            await Task.Delay(1000);
        }
    });

while (await unboundedChannel.Reader.WaitToReadAsync())
{
    if (unboundedChannel.Reader.TryRead(out var message))
    {
        Console.WriteLine($"{DateTime.Now} Read Content: {message}");
    }
}
